import java.util.Arrays;

public class Fibonacci {
    int length;
    private int[] fib;

    Fibonacci(int n) {
        this.length = n;
        try {
            fib = new int[length];
        } catch (NegativeArraySizeException e) {
            System.out.println("Please Input a positive number");
        }
        for (int i = 0; i < n; i++) {
            fib[i] = calcNextFib(i);
        }
    }

    private int calcNextFib(int n) {
        if (n == 0 || n == 1) {
            return 1;
        } else if (n > 1) {
            return fib[n - 1] + fib[n - 2];
        } else {
            return -1;
        }
    }

    void printFib() {
        System.out.println(Arrays.toString(fib));
    }
}